﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SQLExecute;

public partial class list_uers : System.Web.UI.Page
{
    bool bActive;
    int id;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Init_Combo();
           // BindGrid();
            //Get_All_Campus();
            //Get_Dep_Of_Campus();
            //BindGrid();
            //lUser.Text = u.username;
            //lCampusLogin.Text = u.campus;
            
        }

    }
   
   
    /*

    protected void gdUsers_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton l = (LinkButton)e.Row.FindControl("lnkActive");
            l.Attributes.Add("onclick", "javascript:return "
                            + "confirm('Are you sure you want to active/inactive this record: " + DataBinder.Eval(e.Row.DataItem, "fullname") + "')");
        }
    }
    private void Update_Status()
    {
    //    active = !active;
      //  string 
        string sql="select * from tbl_users where id='"+id+"'";
        DataSet ds=SqlHelper.ExecuteDataset(Common.strConnect,CommandType.Text,sql);
        bActive =Convert.ToBoolean (ds.Tables[0].Rows[0]["active"]);
        bActive = !bActive;
        if (bActive)
            sql="update tbl_users set active='1' where id='"+id+"'"; 
        else
            sql = "update tbl_users set active='0' where id='" + id + "'";
        SqlHelper.ExecuteNonQuery(Common.strConnect, CommandType.Text, sql);
    }
    protected void gdUsers_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Update")        
            id = Convert.ToInt16(e.CommandArgument);
    }
    
    protected void gdUsers_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
       
        Update_Status();
        BindGrid();
    }
    protected void cbCampus_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindGrid();
    }
    protected void cbDep_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindGrid();
    }
    protected void btnView_Click(object sender, EventArgs e)
    {
        BindGrid();
    }

    protected void Logout_Click(object sender, EventArgs e)
    {
        Session["username"] = null;
        Response.Redirect("login.aspx");
    }
*/
    protected void Init_Combo()
    {

        
        cbGroup.Items.Insert(0, new ListItem("Users", "Users"));
        cbGroup.Items.Insert(1, new ListItem("Admin", "Admin"));
        cbGroup.SelectedIndex = 0;

    
    }

   
    protected void btnAdd_Click(object sender, EventArgs e)
    {
       

    }
}
